<?php
class Core_Library_Router{
    private static $_instance ;
    private $_request;
    private $_controller;
    private $_action;
    private $_params = array();
    public function parseRequest(){
        return $this->_request = $_SERVER['REQUEST_URI'];
    }
    public static function instance() {
			if( empty( self::$_instance ) )
				self::$_instance = new self() ;
			return self::$_instance ;
		}
    public function getRoute(){
        $splits = explode('/', trim($this->parseRequest(),'/'));
        if(isset($splits['1'])){
            $this->_controller = $splits['1'];
        }else{
            $this->_controller = 'articles';
        }
        if(isset($splits['2'])){
            $this->_action = $splits['2'];
        }else{
            $this->_action = 'index';
        }
        if(isset($splits['3'])){
            $cnt = count($splits);{
            for($i=3; $i<$cnt; $i++)
                $this->_params[] = $splits[$i];
            }
        }else{
            $this->_params = 0;
        }
    }
    public function getController(){
        return $this->_controller;
    }
    public function getAction(){
        return $this->_action;
    }
    public function getParams(){
        return $this->_params;
    }
    
}
